<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">

		<title>购物车页面</title>

		<link href="../AmazeUI-2.4.2/assets/css/amazeui.css" rel="stylesheet" type="text/css" />
		<link href="../basic/css/demo.css" rel="stylesheet" type="text/css" />
		<link href="../css/cartstyle.css" rel="stylesheet" type="text/css" />
		<link href="../css/optstyle.css" rel="stylesheet" type="text/css" />

		<script type="text/javascript" src="../js/jquery.js"></script>
		<script src="../js/login.js"></script>	
	</head>

	<body>

		<!--顶部导航条 -->
		<div class="am-container header">
			<ul class="message-l">
				<div class="topMessage">
					<div class="menu-hd">
						<a href="login.html" target="_top" class="h" id="login">亲，请登录</a>
						<a href="register.html" target="_top">免费注册</a>
					</div>
				</div>
			</ul>
			<ul class="message-r">
				<div class="topMessage home">
					<div class="menu-hd"><a href="home2.html" target="_top" class="h">商城首页</a></div>
				</div>
				<div class="topMessage my-shangcheng">
					<div class="menu-hd MyShangcheng"><a href="index.html" target="_top"><i class="am-icon-user am-icon-fw"></i>个人中心</a></div>
				</div>
				<div class="topMessage mini-cart">
					<div class="menu-hd"><a id="mc-menu-hd" href="shopcart.html" target="_top"><i class="am-icon-shopping-cart  am-icon-fw"></i><span>购物车</span><strong id="J_MiniCartNum" class="h">0</strong></a></div>
				</div>
				<div class="topMessage favorite">
			</ul>
			</div>

			<!--悬浮搜索框-->

			<div class="nav white">
				<div class="logo"><img src="../images/logo.png" /></div>
				<div class="logoBig">
					<li><img src="../images/logobig.png" /></li>
				</div>

				<div class="search-bar pr">
					<a name="index_none_header_sysc" href="search.html"></a>
					<form action="search.html">
						<input id="searchInput" name="index_none_header_sysc" type="text" placeholder="搜索" autocomplete="off">
						<input id="ai-topsearch" class="submit am-btn" value="搜索" index="1" type="submit">
					</form>
				</div>
			</div>

			<div class="clear"></div>

			<!--购物车 -->
			<div class="concent">
				<div id="cartTable">
					<div class="cart-table-th">
						<div class="wp">
							<div class="th th-chk">
								<div id="J_SelectAll1" class="select-all J_SelectAll">

								</div>
							</div>
							<div class="th th-item">
								<div class="td-inner">商品信息</div>
							</div>
							<div class="th th-price">
								<div class="td-inner">单价</div>
							</div>
							<div class="th th-amount">
								<div class="td-inner">数量</div>
							</div>
							<div class="th th-sum">
								<div class="td-inner">金额</div>
							</div>
							<div class="th th-op">
								<div class="td-inner">操作</div>
							</div>
						</div>
					</div>
					<div class="clear" ></div>
			<div id="test">
				<tr class="item-list">
					<div class="bundle  bundle-last ">
						
						<div class="bundle-main"  id="shopcar">
							




							




						</div>
					</div>
				</tr>
			</div>


			<div class="clear"></div>

					
				</div>

				<div class="float-bar-wrapper">
					
					<div class="operations">
						<a href="#" hidefocus="true" onclick="delcars()" class="deleteAll">清空购物车</a>
					</div>
					<div class="float-bar-right">
						<div class="amount-sum">
							<span class="txt">已选商品</span>
							<em id="J_SelectedItemsCount">0</em><span class="txt">件</span>
							<div class="arrow-box">
								<span class="selected-items-arrow"></span>
								<span class="arrow"></span>
							</div>
						</div>
						<div class="price-sum">
							<span class="txt">合计:</span>
							<strong class="price">¥<em id="J_Total">0.00</em></strong>
						</div>
						<div class="btn-area">
							<a href="javascript:;" id="J_Go" class="submit-btn submit-btn-disabled" aria-label="请注意如果没有选择宝贝，将无法结算">
								<span>结&nbsp;算</span></a>
						</div>
					</div>

				</div>

				<div class="footer">
					<div class="footer-hd">
						<p>
								<b>|</b>
								<a href="# ">商城首页</a>
								<b>|</b>
								<a href="# ">支付宝</a>
								<b>|</b>
								<a href="# ">物流</a>
							</p>
						</div>
						<div class="footer-bd ">
							<p>
								<a href="# ">合作伙伴</a>
								<a href="# ">联系我们</a>
								<a href="# ">网站地图</a>
							</p>
					</div>
				</div>

			</div>

			<!--操作页面-->

			<div class="theme-popover-mask"></div>

			<div class="theme-popover">
				<div class="theme-span"></div>
				<div class="theme-poptit h-title">
					<a href="javascript:;" title="关闭" class="close">×</a>
				</div>
				<div class="theme-popbod dform">
					<form class="theme-signin" name="loginform" action="" method="post">

						<div class="theme-signin-left">

							<li class="theme-options">
								<div class="cart-title">颜色：</div>
								<ul>
									<li class="sku-line selected">12#川南玛瑙<i></i></li>
									<li class="sku-line">10#蜜橘色+17#樱花粉<i></i></li>
								</ul>
							</li>
							<li class="theme-options">
								<div class="cart-title">包装：</div>
								<ul>
									<li class="sku-line selected">包装：裸装<i></i></li>
									<li class="sku-line">两支手袋装（送彩带）<i></i></li>
								</ul>
							</li>
							<div class="theme-options">
								<div class="cart-title number">数量</div>
								<dd>
									<input class="min am-btn am-btn-default" name="" type="button" value="-" />
									<input class="text_box" name="" type="text" value="1" style="width:30px;" />
									<input class="add am-btn am-btn-default" name="" type="button" value="+" />
									<span  class="tb-hidden">库存<span class="stock">1000</span>件</span>
								</dd>

							</div>
							<div class="clear"></div>
							<div class="btn-op">
								<div class="btn am-btn am-btn-warning">确认</div>
								<div class="btn close am-btn am-btn-warning">取消</div>
							</div>

						</div>
						<div class="theme-signin-right">
							<div class="img-info">
								<img src="../images/kouhong.jpg_80x80.jpg" />
							</div>
							<div class="text-info">
								<span class="J_Price price-now">¥39.00</span>
								<span id="Stock" class="tb-hidden">库存<span class="stock">1000</span>件</span>
							</div>
						</div>

					</form>
				</div>
			</div>
		<!--引导 -->
		<div class="navCir">
			<li><a href="home2.html"><i class="am-icon-home "></i>首页</a></li>
			<li><a href="sort.html"><i class="am-icon-list"></i>分类</a></li>
			<li class="active"><a href="shopcart.html"><i class="am-icon-shopping-basket"></i>购物车</a></li>	
			<li><a href="../person/index.html"><i class="am-icon-user"></i>我的</a></li>					
		</div>
		
		<script type="text/javascript">
		function getUrlParam(key) {
		    // 获取参数
		    var url = window.location.search;
		    // 正则筛选地址栏
		    var reg = new RegExp("(^|&)" + key + "=([^&]*)(&|$)");
		    // 匹配目标参数
		    var result = url.substr(1).match(reg);
		    //返回参数值
		    return result ? decodeURIComponent(result[2]) : null;
		}
		
			$(function(){
				$.post("../../Shopcar_ViewAllCount",{car_user_id:localStorage.getItem("user_id")},function(count){
					$("#J_SelectedItemsCount").text(count);
				},"json");
				$.post("../../Shopcar_ViewAll",{car_user_id:localStorage.getItem("user_id")},function(res){
					var zongjia=0;
					for (var i = 0; i < res.length; i++) {
						var numprice=res[i].product_discountprice*res[i].car_number;
						zongjia=zongjia+ numprice;
						
						$("#shopcar").append(`
								<ul class="item-content clearfix">
								<li class="td td-item">
								<div class="item-pic">
									<a href="#" target="_blank"
										data-title="${res[i].product_name}"
										class="J_MakePoint" data-point="tbcart.8.12"> <img style="width:80px;height:80px"
										src="../../static/admin/images/${res[i].product_img}"
										class="itempic J_ItemImg"></a>
								</div>
								<div class="item-info">
									<div class="item-basic-info">
										<a href="#" target="_blank" title="美康粉黛醉美唇膏 持久保湿滋润防水不掉色"
											class="item-title J_MakePoint" data-point="tbcart.8.11">${res[i].product_name}</a>
									</div>
								</div>
							</li>
							<li class="td td-info">
								<div class="item-props item-props-can">
									<span class="sku-line">颜色：12#川南玛瑙</span> <span
										class="sku-line">包装：裸装</span> <span tabindex="0"
										class="btn-edit-sku theme-login">修改</span> <i
										class="theme-login am-icon-sort-desc"></i>
								</div>
							</li>
							<li class="td td-price">
								<div class="item-price price-promo-promo">
									<div class="price-content">
										<div class="price-line">
											<em class="price-original">${res[i].product_price}</em>
										</div>
										<div class="price-line">
											<em class="J_Price price-now" tabindex="0">${res[i].product_discountprice}</em>
										</div>
									</div>
								</div>
							</li>
							<li class="td td-amount" >
							<div class="amount-wrapper ">
								<div class="item-amount ">
									<div class="sl">
										<input class="min am-btn" onclick="jian(${res[i].car_number},${res[i].car_id})" type="button" value="-" />
										<input class="text_box" id="carnumber" name="" type="text" value="${res[i].car_number}" style="width: 30px;" /> 
										<input class="add am-btn" onclick="jia(${res[i].car_number},${res[i].car_id})" name="" type="button" value="+" />
									</div>
								</div>
							</div>
						</li>
						<li class="td td-sum">
							<div class="td-inner">
								<em tabindex="0" class="J_ItemSum number">${numprice}</em>
							</div>
						</li>
						<li class="td td-op">
							<div class="td-inner">
								<a href="javascript:;" data-point-url="#" onclick="delcar(${res[i].car_id})" class="delete"> 删除</a>
							</div>
						</li>
						</ul>
								`);
					}
					$("#J_Total").text(zongjia);
					$(document).ready(function(){
						  $("#J_Go").click(function(){
							
							  $(location).attr("href","pay.html?zongjia="+zongjia);
						  });
						});
				},"json");
				
				
				
				
			})
			//加数量
			function jia(i,j){
				var jia=i+1;
					$.post("../../shopUpdate",{car_number:jia,car_id:j},function(res){
						if (res>0) {
							window.location.reload();
						}
					
					},"json");
				}
				//减数量
				function jian(i,j){
					if (i<2) {
						alert("不能再减了");
					}else{
						var jian=i-1;
						$.post("../../shopUpdate",{car_number:jian,car_id:j},function(res){
							if (res>0) {
								window.location.reload();
							}
						
						},"json");
					}
					
					
				}
				function delcar(i){
					$.post("../../shopDelete",{car_id:i},function(res){
						if (res>0) {
							alert("删除成功")
							window.location.reload();
						}
					
					},"json");
				}
				function delcars(){
					$.post("../../shopDeletes",{car_user_id:localStorage.getItem("user_id")},function(res){
						if (res>0) {
							alert("清空购物车成功");
							window.location.reload();
						}
					
					},"json");
				}
		</script>
			<script type="text/javascript">
		//不锁的页面需要用到的东西
		$(function(){
			if (localStorage.getItem("user_id")!=null) {
				//$("#login").html(localStorage.getItem("user_fullname"));
				document.getElementById('login').innerHTML = localStorage.getItem("user_fullname");
			}
		})
		</script>
		
		
	</body>

</html>